#pragma once

#include "Tile.h"
#include "Geometry.h"
//#include "Globals.h"

class Viewport
{
private:
	Vector2 pos;
	Vector2 size;
	float zoom;

public:
	// Position
	float getX() { return Viewport::pos.x; }
	void setX(float x) { Viewport::pos.x = (x * zoom); }
	float getY() { return Viewport::pos.y; }
	void setY(float y) { Viewport::pos.y = (y * zoom); }
	Vector2 getPos() { return pos; }
	void setPos(Vector2 pos) { Viewport::pos = pos; }

	void pan(Vector2 deltaPos);

	// Size
	int getWidth() { return Viewport::size.x; }
	void setWidth(int width) { Viewport::size.x = width; }
	int getHeight() { return Viewport::size.y; }
	void setHeight(int height) { Viewport::size.y = height; }
	Vector2 getSize() { return size; }
	void setSize(Vector2 size) { Viewport::size = size; }

	// Zoom
	void changeZoom(float zoom);
	float getZoom() { return Viewport::zoom; }
	void setZoom(float zoom) { if (zoom > 0.0f) Viewport::zoom = zoom; }

	// HitCheck
	bool isPointInViewport(float x, float y);
	bool isPointInViewport(Vector2 point);
	bool isRectInViewport(float x1, float y1, float x2, float y2);
	bool isRectInViewport(Rectangle2 rect);
	
	bool isTileInViewport(int x, int y);

	// Translation (gameworld <-> screen)
	Vector2 screenToGameworld(int screenX, int screenY);
	Vector2 gameworldToScreen(float gameworldX, float gameworldY);


	void centerTo(int x, int y);
	void centerTo(Vector2 point);
	void centerTo(int x, int y, float zoom);
	void centerTo(Vector2 point, float zoom);

	Viewport(int width, int height);
	Viewport(Vector2 size);
	~Viewport(void);
};

